<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:sgaChooser="http://xmlns.jcp.org/jsf/composite/sgacomp/chooserDialogWindow"
                xmlns:sgaChooserItem="http://xmlns.jcp.org/jsf/composite/sgacomp/chooserDialogWindow/chooserItems" >

    <h:panelGrid columns="3" id="playerForm" >

        <h:outputLabel value="#{bundle.firstName}:" for="firstName" />
        <h:inputText label="#{bundle.firstName}" value="#{player.firstName}" id="firstName"
                     size="40" required="true" maxlength="40"
                     requiredMessage="#{bundle.requiredValidationMessage}"
                     validatorMessage="#{bundle.lengthValidationMessage}" >
            <f:validateRequired />
            <f:validateLength minimum="1" maximum="40" />
            <rich:validator />
        </h:inputText>
        <rich:message for="firstName" />

        <h:outputLabel value="#{bundle.lastName}:" for="lastName"/>
        <h:inputText label="#{bundle.lastName}" value="#{player.lastName}" 
                     id="lastName"
                     size="40" required="true" maxlength="40"
                     requiredMessage="#{bundle.requiredValidationMessage}"
                     validatorMessage="#{bundle.lengthValidationMessage}">
            <f:validateRequired />
            <f:validateLength minimum="1" maximum="40" />
            <rich:validator />
        </h:inputText>
        <rich:message for="lastName" />

        <h:outputLabel value="#{bundle.team}" for="teamSelect" />
        <h:inputText label="#{bundle.team}" value="#{player.team.name}" 
                     id="teamSelect" 
                     styleClass="dialogChooserActivator"
                     size="40" required="true" readonly="true" 
                     requiredMessage="#{bundle.requiredValidationMessage}"
                     onclick="#{rich:component('teamChooserPanel')}.show();">
        </h:inputText>
        <rich:message for="teamSelect" />

        <h:outputLabel value="#{bundle.shirtNumber}:" for="shirtNumber" />
        <rich:select enableManualInput="true" value="#{player.shirtNumber}" 
                     id="shirtNumber" required="true" 
                     requiredMessage="#{bundle.requiredValidationMessage}" 
                     converter="javax.faces.Integer"
                     validatorMessage="#{bundle.numberValidationMessage}">

            <f:selectItems value="#{playerManagedBean.availableShirtNumbers}"
                           var="number" itemValue="#{number}" />
            <f:validateRequired />
            <f:validateLongRange minimum="1" maximum="99" />
            <rich:validator />
        </rich:select>
        <rich:message for="shirtNumber" />

    </h:panelGrid>

    <sgaChooser:chooserDialogWindow dialogChooserID="teamChooserPanel" 
                                    dialogChooserTitle="#{bundle.teamChooserPlayerChooseTeamTitle}" 
                                    dialogChooserItemTitle="#{bundle.teamChooserTeamItemTitle}"
                                    rerendersIDs="teamSelect shirtNumber"
                                    resultListener="#{resultListener}" 
                                    filterFieldName="name" >
        <sgaChooserItem:teamChooserItem />
    </sgaChooser:chooserDialogWindow>

</ui:composition>
